import { Vue } from 'vue-property-decorator';
import { PrefixInteger, numberFormat, unitShow, dateFormat, objToVxeFilterArr } from '@/utils/tools';
import Invest from '@/common/dict/invest';
import ColumnUtil from '@/pages/risk-time/utils/column-util';

export default class MeasureColumnsUtil extends Vue {
    Invest: any = new Invest();
    ColumnUtil = new ColumnUtil();
    // 表格列筛选数据
    filterHandler({ option, row, column }) {
        const property = column['property'];
        return row[property].includes(option.data);
    }

    positionColumn: any[] = [
        { name: '产品代码', val: 'fundCode', width: 110 },
        { name: '产品名称', val: 'fundName', width: 110 },
        { name: '组合编码', val: 'fundAccountCode', width: 110 },
        { name: '证券代码', val: 'stockCode', width: 110, search: true, filters: [{ data: '' }], filterMethod: this.filterHandler },
        { name: '证券名称', val: 'stockNameSt', minWidth: 110, search: true, filters: [{ data: '' }], filterMethod: this.filterHandler },
        {
            name: '持仓数量',
            val: 'marketAmount',
            width: 110,
            type: 'funcNumber',
            funcBody: value => (value != undefined ? numberFormat(value) : '--'),
        },
        {
            name: '持仓市值(元)',
            val: 'marketValue',
            width: 110,
            type: 'funcNumber',
            funcBody: value => (value != undefined ? numberFormat(value, 2) : '--'),
        },
        {
            name: '当前数量',
            val: 'currentAmount',
            width: 110,
            type: 'funcNumber',
            funcBody: value => (value != undefined ? numberFormat(value) : '--'),
        },
        {
            name: '证券市值',
            val: 'totalValue',
            width: 110,
            type: 'funcNumber',
            funcBody: value => (value != undefined ? numberFormat(value, 2) : '--'),
        },
        { name: '多空类型', val: 'bullberType', width: 110, type: 'status', statusKV: this.Invest.bullbearType },
        { name: '证券内评', val: 'stockOuterGradeInfo', width: 110 },
        { name: '证券外评', val: 'stockInnergradeInfo', width: 110 },
        { name: '发行人内评', val: 'issueOuterGradeInfo', width: 110 },
        { name: '发行人外评', val: 'issueInnergradeInfo', width: 110 },
    ];

    get positionColumns() {
        return this.ColumnUtil.handleTrailPositionColumns(this.positionColumn, 'val');
    }

    // 存款
    depositPositionColumn: any[] = [
        { name: '存单号', val: 'receiptNo', width: 110 },
        { name: '产品代码', val: 'fundCode', width: 110 },
        { name: '产品名称', val: 'fundNameSt', width: 110 },
        { name: '组合编码', val: 'fdAcCode', width: 110 },
        { name: '持仓日期', val: 'positionDate', width: 110 },
        {
            name: '持仓市值',
            val: 'marketValue',
            width: 110,
            type: 'func',
            funcBody: value => (value != undefined ? numberFormat(value, 2) : '--'),
        },
        { name: '存入日期', val: 'depositDate', width: 80 },
        { name: '起息日', val: 'startDate', width: 80 },
        { name: '止息日', val: 'endDate', width: 110 },
        {
            name: '存款余额',
            val: 'depositBalance',
            width: 110,
            type: 'func',
            funcBody: value => (value != undefined ? numberFormat(value, 2) : '--'),
        },
        { name: '存款利率', val: 'depositRate', width: 110, type: 'status', statusKV: this.Invest.bullbearType },
        { name: '存款类型', val: 'depositType', width: 110 },
        { name: '支取类型', val: 'advanceType', width: 110 },
        { name: '存款总行', val: 'bankCode', width: 110 },
        { name: '存款人', val: 'depositUser', width: 110 },
    ];

    get depositPositionColumns() {
        return this.ColumnUtil.handleTrailPositionColumns(this.depositPositionColumn, 'val');
    }

    // 转融通持仓信息
    securityLoanPositionColumn: any = [
        { name: '日期', val: 'ddate', width: 110 },
        { name: '成交日期', val: 'dealDate', width: 110 },
        { name: '持仓序号', val: 'positionId', width: 110 },
        { name: '基金序号', val: 'fundCode', width: 110 },
        { name: '基金名称', val: 'fundNameSt', width: 110 },
        { name: '组合编码', val: 'fdAcCode', width: 110 },
        { name: '投资类型', val: 'investType', width: 110 },
        { name: '市场编号', val: 'marketCode', width: 110 },
        { name: '证券代码', val: 'stockCode', width: 110 },
        { name: '合约编号', val: 'contractNo', width: 110 },
        { name: '成交编号', val: 'dealNo', width: 110 },
        { name: '合约类型', val: 'contractType', width: 110 },
        { name: '转融通类别', val: 'zrtType', width: 110 },
        { name: '委托方向', val: 'entrustDirection', width: 110 },
        { name: '借贷天数', val: 'redeemDays', width: 110 },
    ];

    get securityLoanPositionColumns() {
        return this.ColumnUtil.handleTrailPositionColumns(this.securityLoanPositionColumn, 'val');
    }
}
